<%@ page language="java" import="java.util.*,school.dao.*,school.entity.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'students.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <h1>学员列表</h1>
    <%
    	int pageNo=1;//当前页
    	try{
    		pageNo=Integer.parseInt(request.getParameter("pageNo"));
    	}catch(Exception e){
    		//在这里处理错误
    	}
    	if(pageNo<1){
    		//pageNo=1;
    		out.print("<h2>已经是首页了</h2>");
    		return;
    	}
    	
    	StudentDao sdao=new MySqlStudentDao();
    	Page<Student> p=sdao.query(pageNo);
    %>
    <ul>
    <%for(Student s:p.getDatas()){ %>
     <li><%=s.getStuno()%>=<%=s.getSname() %>&nbsp;</li>
    <%} %>
    </ul>
    <p>
    <!-- students.jsp生成的html连接到students.jsp -->
    <a href="students.jsp?pageNo=1">首页</a>
    <%if(pageNo>1){%>
    <a href="students.jsp?pageNo=<%=pageNo-1%>">上一页</a>
    <%} %>
    <%if(pageNo<p.getTotalPages()){ %>
    <a href="students.jsp?pageNo=<%=pageNo+1%>">下一页</a>
    <%} %> 
    <a href="students.jsp?pageNo=<%=p.getTotalPages()%>">末页</a>
    </p>
  </body>
</html>
